package com.d3works.apps.cash.management.web;

import com.d3works.apps.cash.management.db.ForecastGenerator;
import com.d3works.apps.cash.management.db.repo.ForecastGeneratorRepository;
import com.d3works.apps.cash.management.service.ForecastService;
import com.d3works.inject.Beans;
import com.d3works.rpc.ActionRequest;
import com.d3works.rpc.ActionResponse;

public class ForecastController {

  public void generate(ActionRequest request, ActionResponse response) {
    ForecastGenerator forecastGenerator = request.getContext().asType(ForecastGenerator.class);
    forecastGenerator =
        Beans.get(ForecastGeneratorRepository.class).find(forecastGenerator.getId());
    Beans.get(ForecastService.class).generate(forecastGenerator);
    response.setReload(true);
  }
}
